<?php 

/**
 * @category Noginn
 * @package Noginn_Geocoder
 */
class Noginn_Geocoder_Location
{
    /**
     * The latitude coordinate of the geocoded address
     *
     * @var float
     **/
    public $latitude;
    
    /**
     * The longitude coordinate of the geocoded address
     *
     * @var float
     **/
    public $longitude;
    
    /**
     * How acurately the address was geocoded.
     * The larger the integer the greater the accuracy.
     *
     * @var int
     */
    public $accuracy = 0;
    
    /**
     * Full address string
     *
     * @var string
     */
    public $address;
    
    /**
     * The street or building address
     *
     * @var string
     */
    public $street;
    
    /**
     * The city or town
     *
     * @var string
     */
    public $city;
    
    /**
     * The region of the locality.
     * Synonyms: state, county
     *
     * @var string
     */
    public $region;

    /**
     * The postal code. 
     * Synonyms: zip
     *
     * @var string
     */
    public $postalCode;
    
    /**
     * The 2 letter country code
     *
     * @var string
     */
    public $country;
    
    /**
     * Get the variable by name or synonym
     *
     * @param string $name 
     * @return mixed
     */
    public function __get($name)
    {
        switch ($name) {
            case 'state':
            case 'county':
                return $this->state;
                break;
            case 'zip':
                return $this->zip;
                break;
            default:
                return $this->{$name};
                break;
        }
    }
    
    /**
     * Set the variable by name or synonym
     *
     * @param string $name 
     * @param string $value 
     * @return void
     */
    public function __set($name, $value)
    {
        switch ($name) {
            case 'state':
            case 'county':
                $this->state = $value;
                break;
            case 'zip':
                $this->zip = $value;
                break;
            default:
                $this->{$name} = $value;
                break;
        }
    }
}